import cv2
import numpy as np
import os
image1 = cv2.imread(r'E:\python\logo1.png')
image2 = cv2.imread(r'E:\python\logo2.png')
if image1 is None or image2 is None:
    print("path     wrong")
    try:
        os._exit(0)
    except:
        print('Program is dead.')
print("image ok")

orb = cv2.ORB_create()
kp1 = orb.detect(image1, None)
kp2 = orb.detect(image2, None)

kp1, des1 = orb.compute(image1, kp1)
kp2, des2 = orb.compute(image2, kp2)

bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

image1 = cv2.drawKeypoints(image1,kp1,image1,color=(0,0,255), flags=0)
image2 = cv2.drawKeypoints(image2,kp2,image2,color=(0,0,255), flags=0)

matcher = bf.match(des1, des2)
img_mathes = cv2.drawMatches(image1, kp1, image2, kp2, matcher, None, (0, 0, 255))
cv2.imshow('img_mathes',img_mathes)
cv2.waitKey(0)
cv2.destroyAllWindows()
